using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Entities;
using BUS;
using Utility;
using DAL;

public partial class Admin_MaSoSPUpdate : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            LoadData();
    }
    private void LoadData()
    {
        try
        {
            int id = int.Parse(Request.QueryString["id"].ToString());
            txt_id_mssp.Text = id.ToString();
            tbMaSoSP mssp = tbMaSoSPBUS.GetByID(id);
            tbChiTietDH .tbChiTietDHCollection  ctdh_collection = tbChiTietDHBUS .GetAll();
            ddl_ctdh.DataTextField = tbChiTietDH .tbChiTietDHColumns .IDCTDH .ToString();
            ddl_ctdh.DataValueField = tbChiTietDH .tbChiTietDHColumns .IDCTDH .ToString();
            ddl_ctdh.DataSource = ctdh_collection;
            ddl_ctdh.DataBind();
        }
        catch
        {
            Response.Redirect("MaSoSPList.aspx");
        }
    }
    protected void btn_Update_Click(object sender, EventArgs e)
    {
        int id = int.Parse(Request.QueryString["id"].ToString());
        tbMaSoSP mssp = tbMaSoSPBUS.GetByID(id);
        mssp.IDMSSP  = int.Parse(txt_id_mssp.Text);
        mssp.IDCTDH = int.Parse(ddl_ctdh.SelectedValue);
        mssp.MaSo = int.Parse(txt_maso.Text);
        mssp.TrangThai = txt_trangthai.Text;
        tbMaSoSPBUS.Update_MaSoSP (mssp);
        Response.Redirect("MaSoSPList.aspx");
    }
}
